{template header}
<script src="static/bootstrap/js/utils.js"></script>
<link rel="stylesheet" href="static/calendar/js/calendar.css" />
<script type="text/javascript" charset="utf-8" src="static/calendar/calendar.php"></script>
<style type="text/css">


</style>
<style type="text/css">
    label{float: left;margin: auto 10px;}
</style>
<form class="form-horizontal" action="index.php?c=admin&a=actHandle" method="post" enctype="multipart/form-data">
    <div class="control-group">
        <label class="control-label" for="inputTiltle">标题：</label>
        <div class="controls">
            <input type="text" name='title' placeholder="请输入标题" value="{$info['title']}">
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputTiltle">副标题：</label>
        <div class="controls">
            <input type="text" name='short_desc' placeholder="请输入副标题" value="{$info['short_desc']}">
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputShortDesc">类型：</label>
        <div class="controls">
            <select name="type" id="type">
                <option value="3">目标里程</option>
                <option {if $info['type'] == 4} selected="selected" {/if} value="4">打卡</option>
                <option {if $info['type'] == 5} selected="selected" {/if} value="5">自定义</option>
            </select>
        </div>
    </div>
    <div class="control-group" id="rule">
        <label class="control-label" for="inputTiltle">活动规则：</label>
        <div class="controls">
            <textarea name='rule' placeholder="请输入活动规则">{$info['rule']}</textarea>
        </div>
    </div>
    <div class="control-group" id="gift_type">
        <label class="control-label" for="inputShortDesc">奖励类型：</label>
        <div class="controls">
            <select name="gift_type">
                <option value="-1">请选择</option>
                {loop $giftType $k $v}
                <option value="{$k}" {if $info['gift_type'] == $k} selected {/if}>{$v}</option>
                {/loop}
            </select>
        </div>
    </div>
    <div class="control-group" id="gift_id">
        <label class="control-label" for="inputShortDesc">奖品ID：</label>
        <div class="controls">
            <input type="text" name="gift_id" value="{$info['gift_id']}" placeholder="请输入勋章ID或商品ID"/>
        </div>
    </div>
    <div class="control-group" id="target">
        <label class="control-label" for="inputTiltle">目标数：</label>
        <div class="controls">
            <input type="text" value="{$info['target']}" name='target' placeholder="请输入目标数">KM
        </div>
    </div>
    <div class="control-group" id="days" {if $info['type'] != 4}style="display: none"{/if}>
        <label class="control-label" for="inputTiltle">打卡天数：</label>
        <div class="controls">
            <input type="text" value="{$info['days']}" name='days' placeholder="请输入打卡天数">天
        </div>
    </div>
    <div class="control-group  pr" >
        <label class="control-label" for="inputauthor">封面图：</label>
        <div class="controls">
            {if $info['img']} <img width="100px" height="100px" src="{$info['img']}"/>{/if}
            <input type="file" name="img" />
        </div>

    </div>
    <div class="control-group">
        <label class="control-label" for="inputstarttime">开始时间：</label>
        <div class="controls">
            <input type="text" name="stime" readonly="readonly" id="starttimeid" value="{eval echo date('Y-m-d H:i:s', ($info['stime']>0?$info['stime']:time()+10800))}">
            <input name="starttimebtn" type="button" id="starttimebtn" onclick="return showCalendar('starttimeid', '%Y-%m-%d %H:%M:%S', '24', false, 'starttimebtn');" value="选择" class="button" />
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputstarttime">结束时间：</label>
        <div class="controls">
            <input type="text" name="etime" readonly="readonly" id="endtimeid" value="{eval echo date('Y-m-d H:i:s', $info['etime']>0?$info['etime']:time()+14400)}">
            <input name="starttimebtn" type="button" id="endtimebtn" onclick="return showCalendar('endtimeid', '%Y-%m-%d %H:%M:%S', '24', false, 'starttimebtn');" value="选择" class="button" />
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputtag">活动介绍：</label>
        <div class="controls">
            <textarea name="introduce">{$info['introduce']}</textarea>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputtag">活动费用：</label>
        <div class="controls">
            <input type="text" name="cost" value="{eval echo floatval($info['cost'])}"/>元
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputtag">费用介绍：</label>
        <div class="controls">
            <textarea name="cost_content">{if isset($info['cost_content'])}{$info['cost_content']}{/if}</textarea>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputtag">活动URL：</label>
        <div class="controls">
            <input type="text" name="url" value="{$info['url']}"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputtag">活动地点：</label>
        <div class="controls">
            <input type="text" value="{$info['place']}" name="place"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputtag">广告位：</label>
        <div class="controls">
            {if isset($info['banner'][0]['img'])} <img width="100px" height="100px" src="{$info['banner'][0]['img']}"/>{/if}
            <input type="file" name="banner_img" />
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputtag">广告位链接：</label>
        <div class="controls">
            <input type="text" id="link" name="link" {if isset($info['banner'][0]['link'])} value="{$info['banner'][0]['link']}"{/if} style="width: 430px;"> <span><a class="btn-info" href="javascript:void(0)" data="{$uri}" onclick="fillUrl(this)">商品详情</a></span>
        </div>
    </div>
    <div class="control-group">
        <div class="controls">
            <input type="hidden" name="action" value="update"/>
            <input type="hidden" name="id" value="{$info['aid']}"/>
            {if $info['type'] > 2 || empty($info)}<button type="submit" class="btn">提交</button>{/if}
        </div>
    </div>
</form>


{template footer}
<script>
    $(function(){
        $("#type").change(function(){
            if($(this).val() == 4){
                $("#days").show();
                $("#rule").show();
                $("#gift_id").show();
                $("#gift_type").show();
            }
            if($(this).val() == 5){
                $("#days").hide();
                $('#target').hide();
                $("#rule").hide();
                $("#gift_id").hide();
                $("#gift_type").hide();
            }
            if($(this).val() == 3){
                $('#target').show();
                $('#days').hide();
                $("#rule").show();
                $("#gift_id").show();
                $("#gift_type").show();
            }
        });
    })
    function fillUrl(obj){
        var url = $(obj).attr('data');
        $('#link').val(url);
    }
</script>